package com.zmzncs.lmtc.module.promotion.pojo.customize_rule;


import com.zmzncs.lmtc.common.util.ExceptionUtil;
import com.zmzncs.lmtc.common.pojo.enums.optionalvalue.promotion.RuleStatusEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * <p>
 * 
 * </p>
 *
 * @author 任建波
 * @since 2020-08-13
 */
@Data
public class CustomizeRuleUpdateForm implements Serializable {

    private static final long serialVersionUID=1L;

    @ApiModelProperty(value = "2个停车场状态（1：开启，0：关闭）", required = true)
    @NotNull
    private RuleStatusEnum twoParkStatus;
    @ApiModelProperty(value = "2个停车场年折率")
    private BigDecimal twoParkMonthDiscountRate = new BigDecimal(100);
    @ApiModelProperty(value = "2个停车场季折率")
    private BigDecimal twoParkQuarterDiscountRate = new BigDecimal(100);
    @ApiModelProperty(value = "2个停车场年折率")
    private BigDecimal twoParkYearDiscountRate = new BigDecimal(100);

    @ApiModelProperty(value = "3个停车场状态（1：开启，0：关闭）", required = true)
    @NotNull
    private RuleStatusEnum threeParkStatus;
    @ApiModelProperty(value = "3个停车场月折率")
    private BigDecimal threeParkMonthDiscountRate = new BigDecimal(100);
    @ApiModelProperty(value = "3个停车场季折率")
    private BigDecimal threeParkQuarterDiscountRate = new BigDecimal(100);
    @ApiModelProperty(value = "3个停车场年折率")
    private BigDecimal threeParkYearDiscountRate = new BigDecimal(100);

    @ApiModelProperty(value = "4个停车场状态（1：开启，0：关闭）", required = true)
    @NotNull
    private RuleStatusEnum fourParkStatus;
    @ApiModelProperty(value = "4个停车场月折率")
    private BigDecimal fourParkMonthDiscountRate = new BigDecimal(100);
    @ApiModelProperty(value = "4个停车场季折率")
    private BigDecimal fourParkQuarterDiscountRate = new BigDecimal(100);
    @ApiModelProperty(value = "4个停车场年折率")
    private BigDecimal fourParkYearDiscountRate = new BigDecimal(100);

    @ApiModelProperty(value = "5个停车场状态（1：开启，0：关闭）", required = true)
    @NotNull
    private RuleStatusEnum fiveParkStatus;
    @ApiModelProperty(value = "5个停车场月折率")
    private BigDecimal fiveParkMonthDiscountRate = new BigDecimal(100);
    @ApiModelProperty(value = "5个停车场季折率")
    private BigDecimal fiveParkQuarterDiscountRate = new BigDecimal(100);
    @ApiModelProperty(value = "5个停车场年折率")
    private BigDecimal fiveParkYearDiscountRate = new BigDecimal(100);

    public void validate(){
        if(twoParkStatus == RuleStatusEnum.OPEN){
            if(twoParkMonthDiscountRate.compareTo(BigDecimal.ZERO) <= 0
                || twoParkQuarterDiscountRate.compareTo(BigDecimal.ZERO) <= 0
                || twoParkYearDiscountRate.compareTo(BigDecimal.ZERO) <= 0
            ){
                ExceptionUtil.paramException("2个停车场的折率不能小于0");
            }
        }
        if(threeParkStatus == RuleStatusEnum.OPEN){
            if(threeParkMonthDiscountRate.compareTo(BigDecimal.ZERO) <= 0
                || threeParkQuarterDiscountRate.compareTo(BigDecimal.ZERO) <= 0
                || threeParkYearDiscountRate.compareTo(BigDecimal.ZERO) <= 0
            ){
                ExceptionUtil.paramException("3个停车场的折率不能小于0");
            }
        }
        if(fourParkStatus == RuleStatusEnum.OPEN){
            if(fourParkMonthDiscountRate.compareTo(BigDecimal.ZERO) <= 0
                    || fourParkQuarterDiscountRate.compareTo(BigDecimal.ZERO) <= 0
                    || fourParkYearDiscountRate.compareTo(BigDecimal.ZERO) <= 0
            ){
                ExceptionUtil.paramException("4个停车场的折率不能小于0");
            }
        }
        if(fiveParkStatus == RuleStatusEnum.OPEN){
            if(fiveParkMonthDiscountRate.compareTo(BigDecimal.ZERO) <= 0
                || fiveParkQuarterDiscountRate.compareTo(BigDecimal.ZERO) <= 0
                || fiveParkYearDiscountRate.compareTo(BigDecimal.ZERO) <= 0
            ){
                ExceptionUtil.paramException("5个停车场的折率不能小于0");
            }
        }
    }
}
